<?php

/**
 * AbetStudent form base class.
 *
 * @method AbetStudent getObject() Returns the current form's model object
 *
 * @package    sfproject
 * @subpackage form
 * @author     Your name here
 */
abstract class BaseAbetStudentForm extends BaseFormPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'              => new sfWidgetFormInputHidden(),
      'instructor_Code' => new sfWidgetFormPropelChoice(array('model' => 'AbetInstructor', 'add_empty' => true, 'key_method' => 'getCode')),
      'department_Code' => new sfWidgetFormPropelChoice(array('model' => 'AbetDepartment', 'add_empty' => true, 'key_method' => 'getCode')),
      'code'            => new sfWidgetFormInputText(),
      'name'            => new sfWidgetFormInputText(),
      'password'        => new sfWidgetFormInputText(),
      'start_Date'      => new sfWidgetFormDate(),
      'level_Number'    => new sfWidgetFormInputText(),
      'birth_Date'      => new sfWidgetFormInputText(),
      'sex'             => new sfWidgetFormInputText(),
      'degree'          => new sfWidgetFormInputText(),
      'gpa'             => new sfWidgetFormInputText(),
      'email'           => new sfWidgetFormInputText(),
      'mobile'          => new sfWidgetFormInputText(),
      'created_at'      => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'              => new sfValidatorChoice(array('choices' => array($this->getObject()->getId()), 'empty_value' => $this->getObject()->getId(), 'required' => false)),
      'instructor_Code' => new sfValidatorPropelChoice(array('model' => 'AbetInstructor', 'column' => 'code', 'required' => false)),
      'department_Code' => new sfValidatorPropelChoice(array('model' => 'AbetDepartment', 'column' => 'code', 'required' => false)),
      'code'            => new sfValidatorInteger(array('min' => -2147483648, 'max' => 2147483647, 'required' => false)),
      'name'            => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'password'        => new sfValidatorString(array('max_length' => 20)),
      'start_Date'      => new sfValidatorDate(),
      'level_Number'    => new sfValidatorString(array('max_length' => 2)),
      'birth_Date'      => new sfValidatorInteger(array('min' => -2147483648, 'max' => 2147483647)),
      'sex'             => new sfValidatorString(array('max_length' => 2)),
      'degree'          => new sfValidatorString(array('max_length' => 20)),
      'gpa'             => new sfValidatorNumber(),
      'email'           => new sfValidatorString(array('max_length' => 30, 'required' => false)),
      'mobile'          => new sfValidatorString(array('max_length' => 10, 'required' => false)),
      'created_at'      => new sfValidatorDateTime(array('required' => false)),
    ));

    $this->validatorSchema->setPostValidator(
      new sfValidatorAnd(array(
        new sfValidatorPropelUnique(array('model' => 'AbetStudent', 'column' => array('code'))),
        new sfValidatorPropelUnique(array('model' => 'AbetStudent', 'column' => array('name'))),
      ))
    );

    $this->widgetSchema->setNameFormat('abet_student[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'AbetStudent';
  }


}
